﻿using ERP_RORZE_DLL.Product.Base;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ERP_RORZE_PRODUCT.Product.DAO
{
    class ClsLinkVCuongDAO : ExecuteSQL
    {
        ExecuteSQL Execute = new ExecuteSQL();
        #region các các bảng trong file LinhVCuong
        //Nhập lệnh tính thời gian GC

        public DataTable GetAllGC()
        {
            string sql = clsConstBasicListFuction.ClsReportFuction.GC.GetAll;
            return Execute.DoStoreProcedure(sql, true);
        }

        public DataTable GetAllKHTon()
        {
            string sql = clsConstBasicListFuction.ClsReportFuction.GC.GetAllKHTon;
            return Execute.DoStoreProcedure(sql, true);
        }

        //Nhập ĐH lấy dữ liệu KH gia công
        public DataTable GetAllKHGC()
        {
            string sql = clsConstBasicListFuction.ClsReportFuction.KHGC.GetAll;
            return Execute.DoStoreProcedure(sql, true);
        }

        public DataTable GetAllDLM()
        {
            string sql = clsConstBasicListFuction.ClsReportFuction.KHGC.GetAllDLM;
            return Execute.DoStoreProcedure(sql, true);
        }

        public DataTable GetAllKHGC03()
        {
            string sql = clsConstBasicListFuction.ClsReportFuction.KHGC.GetAllKHGC03;
            return Execute.DoStoreProcedure(sql, true);
        }

        //Nhập ĐH lấy dữ liệu KH Kiểm tra --P_NhapOrderlapKHKtra
        public DataTable GetAllKHKT()
        {
            string sql = clsConstBasicListFuction.ClsReportFuction.KHKT.GetAll;
            return Execute.DoStoreProcedure(sql, true);
        }

        public DataTable GetAllKHKT24()
        {
            string sql = clsConstBasicListFuction.ClsReportFuction.KHKT.GetAllKHKT24;
            return Execute.DoStoreProcedure(sql, true);
        }

        //Nhập oder lập KHNC Vỉa
        public DataTable GetAllKHNCV()
        {
            string sql = clsConstBasicListFuction.ClsReportFuction.KHNCV.GetAll;
            return Execute.DoStoreProcedure(sql, true);
        }

        public DataTable GetAllKHNCV24()
        {
            string sql = clsConstBasicListFuction.ClsReportFuction.KHNCV.GetAllKHNCV24;
            return Execute.DoStoreProcedure(sql, true);
        }

        public DataTable GetAllKHNCV25()
        {
            string sql = clsConstBasicListFuction.ClsReportFuction.KHNCV.GetAllKHNCV25;
            return Execute.DoStoreProcedure(sql, true);
        }

        public DataTable GetAllKHNCV26()
        {
            string sql = clsConstBasicListFuction.ClsReportFuction.KHNCV.GetAllKHNCV26;
            return Execute.DoStoreProcedure(sql, true);
        }

        // Nhập ĐH lấy dữ liệu kiểm tra -- TnhapOrder

        public DataTable GetAllTnhapOrder()
        {
            string sql = clsConstBasicListFuction.ClsReportFuction.KHKT06.GetAllTnhapOder;
            return Execute.DoStoreProcedure(sql, true);
        }
        public DataTable GetAllDHMN()
        {
            string sql = clsConstBasicListFuction.ClsReportFuction.KHKT06.GetAllDHMN;
            return Execute.DoStoreProcedure(sql, true);
        }

        public DataTable GetAllKHKT06()
        {
            string sql = clsConstBasicListFuction.ClsReportFuction.KHKT06.GetAllKHKT06;
            return Execute.DoStoreProcedure(sql, true);
        }
        #endregion
        #region Báo cáo trong file LinkVCuong
        // các báo cáo trong file linkvcuong
        //1
        public DataTable ZDH()
        {
            string sql = clsConstBasicListFuction.ClsReportFuction.OTHER.GetAllZDH;
            return Execute.DoStoreProcedure(sql, true);
        }
        //2
        public DataTable XThanh_LayNCtamthoi()
        {
            string sql = clsConstBasicListFuction.ClsReportFuction.OTHER.GetAllXThanh_LayNCtamthoi;
            return Execute.DoStoreProcedure(sql, true);
        }
        //3
        public DataTable VitrihangVIA_KTRA(DateTime From, DateTime To)
        {
            string sql = clsConstBasicListFuction.ClsReportFuction.OTHER.VIAKTRA;
            var parameter = new SqlParameter[]
                {
                    CreateParameter("@BatDau", SqlDbType.DateTime, From),
                    CreateParameter("@KetThuc", SqlDbType.DateTime, To)
                    
                };
            return Execute.DoStoreGetByID(sql,parameter, true);
        }
        //4
        public DataTable VitrihangMAY_VIA(DateTime From, DateTime To)
        {
            string sql = clsConstBasicListFuction.ClsReportFuction.OTHER.GetAllMAVIA;
            var parameter = new SqlParameter[]
                {
                    CreateParameter("@BatDau", SqlDbType.DateTime, From),
                    CreateParameter("@KetThuc", SqlDbType.DateTime, To)
                    
                };
            return Execute.DoStoreGetByID(sql, parameter, true);
        }
        //5
        public DataTable VanthongkedulieuXLBM(DateTime From, DateTime To)
        {
            string sql = clsConstBasicListFuction.ClsReportFuction.OTHER.GetAllXLBM;
            var parameter = new SqlParameter[]
                {
                    CreateParameter("@BatDau", SqlDbType.DateTime, From),
                    CreateParameter("@KetThuc", SqlDbType.DateTime, To)
                    
                };
            return Execute.DoStoreGetByID(sql, parameter, true);
        }
        //6
        public DataTable VanthongkedulieuVIA(DateTime From, DateTime To)
        {
            string sql = clsConstBasicListFuction.ClsReportFuction.OTHER.GetAllDLVIA;
            var parameter = new SqlParameter[]
                {
                    CreateParameter("@BatDau", SqlDbType.DateTime, From),
                    CreateParameter("@KetThuc", SqlDbType.DateTime, To)
                    
                };
            return Execute.DoStoreGetByID(sql, parameter, true);
        }
        //7
        public DataTable VanthongkedulieuKTra(DateTime From, DateTime To)
        {
            string sql = clsConstBasicListFuction.ClsReportFuction.OTHER.GetAllDLKTRA;
            var parameter = new SqlParameter[]
                {
                    CreateParameter("@BatDau", SqlDbType.DateTime, From),
                    CreateParameter("@KetThuc", SqlDbType.DateTime, To)
                    
                };
            return Execute.DoStoreGetByID(sql, parameter, true);
        }
        //8
        public DataTable Udonhang()
        {
            string sql = clsConstBasicListFuction.ClsReportFuction.OTHER.GetAllUDONHANG;
            return Execute.DoStoreProcedure(sql, true);
        }
        //9
        public DataTable UDH_KH()
        {
            string sql = clsConstBasicListFuction.ClsReportFuction.OTHER.GetAllUDHKH;
            return Execute.DoStoreProcedure(sql, true);
        }
        //10
        public DataTable TK_HoanthanhKHtrongthang(DateTime From, DateTime To)
        {
            string sql = clsConstBasicListFuction.ClsReportFuction.OTHER.GetAllKHTrongThang;
            var parameter = new SqlParameter[]
                {
                    CreateParameter("@BatDau", SqlDbType.DateTime, From),
                    CreateParameter("@KetThuc", SqlDbType.DateTime, To)
                    
                };
            return Execute.DoStoreGetByID(sql, parameter, true);
        }
        //11
        public DataTable TK_Congsuatmay(DateTime From, DateTime To)
        {
            string sql = clsConstBasicListFuction.ClsReportFuction.OTHER.GetAllCongSuatMay;
            var parameter = new SqlParameter[]
                {
                    CreateParameter("@BatDau", SqlDbType.DateTime, From),
                    CreateParameter("@KetThuc", SqlDbType.DateTime, To)
                    
                };
            return Execute.DoStoreGetByID(sql, parameter, true);
        }
        //12
        public DataTable TK_CongsuatKHVia()
        {
            string sql = clsConstBasicListFuction.ClsReportFuction.OTHER.GetAllCongSuatKHVia;
            return Execute.DoStoreProcedure(sql, true);
        }
        //13
        //public DataTable GetAllCongSuatKHVia()
        //{
        //    string sql = clsConstBasicListFuction.ClsReportFuction.OTHER.GetAllCongSuatKHVia;
        //    return Execute.DoStoreProcedure(sql, true);
        //}
        //13
        public DataTable TK_CongsuatKHKtra()
        {
            string sql = clsConstBasicListFuction.ClsReportFuction.OTHER.GetAllCongSuatKHKTra;
            return Execute.DoStoreProcedure(sql, true);
        }
        //14
        public DataTable QStaffDailyTime()
        {
            string sql = clsConstBasicListFuction.ClsReportFuction.OTHER.GetAllQStaffDailyTime;
            return Execute.DoStoreProcedure(sql, true);
        }
        //15
        public DataTable QMachineDailyTime()
        {
            string sql = clsConstBasicListFuction.ClsReportFuction.OTHER.GetAllQMachineDailyTime;
            return Execute.DoStoreProcedure(sql, true);
        }
        //16
        public DataTable P_InsData_Luu()
        {
            string sql = clsConstBasicListFuction.ClsReportFuction.OTHER.GetAllInsDataLuu;
            return Execute.DoStoreProcedure(sql, true);
        }
        //17
        public DataTable Le_LaydulieuPIN1()
        {
            string sql = clsConstBasicListFuction.ClsReportFuction.OTHER.GetAllPIN1;
            return Execute.DoStoreProcedure(sql, true);
        }
        //18
        public DataTable KH_TGconlaicuadonhang02(DateTime From, DateTime To)
        {
            string sql = clsConstBasicListFuction.ClsReportFuction.OTHER.GetAllTGConLaiDH02;
            var parameter = new SqlParameter[]
                {
                    CreateParameter("@BatDau", SqlDbType.DateTime, From),
                    CreateParameter("@KetThuc", SqlDbType.DateTime, To)
                    
                };
            return Execute.DoStoreGetByID(sql, parameter, true);
        }
        //19
        public DataTable KH_TGconlaicuadonhang01()
        {
            string sql = clsConstBasicListFuction.ClsReportFuction.OTHER.GetAllTGConLaiDH01;
            return Execute.DoStoreProcedure(sql, true);
        }
        //20
        public DataTable KH_DonhangchuaXINLENH(DateTime From, DateTime To)
        {
            string sql = clsConstBasicListFuction.ClsReportFuction.OTHER.GetAllDonHangChuaXinLenh;
            var parameter = new SqlParameter[]
                {
                    CreateParameter("@BatDau", SqlDbType.DateTime, From),
                    CreateParameter("@KetThuc", SqlDbType.DateTime, To)
                    
                };
            return Execute.DoStoreGetByID(sql, parameter, true);
        }
        //21
        public DataTable KH_DonhangchuaSTART(DateTime From, DateTime To)
        {
            string sql = clsConstBasicListFuction.ClsReportFuction.OTHER.GetAllDonHangChuaStart;
            var parameter = new SqlParameter[]
                {
                    CreateParameter("@BatDau", SqlDbType.DateTime, From),
                    CreateParameter("@KetThuc", SqlDbType.DateTime, To)
                    
                };
            return Execute.DoStoreGetByID(sql, parameter, true);
        }
        //22
        public DataTable InsTime_Thanh0673()
        {
            string sql = clsConstBasicListFuction.ClsReportFuction.OTHER.GetAllThanh0673;
            return Execute.DoStoreProcedure(sql, true);
        }

        #endregion

        #region các báo cáo trong mục báo cáo kế hoạch

        public DataTable PWTSDelete()
        {
            string sql = clsConstBasicListFuction.ClsReportFuction.BCKH.PWTSDelete;
            return Execute.DoStoreProcedure(sql, true);
        }

        public DataTable PWTSUpdate(DateTime Date)
        {
            string sql = clsConstBasicListFuction.ClsReportFuction.BCKH.PWTSUpdate;
            var parameter = new SqlParameter[]
                {
                    CreateParameter("@Date", SqlDbType.DateTime, Date)
                    
                };
            return Execute.DoStoreGetByID(sql, parameter, true);
        }
        public DataTable QBCBieuThoigianchaymayNgayVN()
        {
            string sql = clsConstBasicListFuction.ClsReportFuction.BCKH.QBCBieuThoigianchaymayNgayVN;
            return Execute.DoStoreProcedure(sql, true);
        }
        public DataTable QBCBieuthoigianchaymayNgayJP()
        {
            string sql = clsConstBasicListFuction.ClsReportFuction.BCKH.QBCBieuthoigianchaymayNgayJP;
            return Execute.DoStoreProcedure(sql, true);
        }
        public DataTable QTGCMCross_CrosstabVN()
        {
            string sql = clsConstBasicListFuction.ClsReportFuction.BCKH.QTGCMCross_CrosstabVN;
            return Execute.DoStoreProcedure(sql, true);
        }
        public DataTable QTGCMCross_CrosstabJP()
        {
            string sql = clsConstBasicListFuction.ClsReportFuction.BCKH.QTGCMCross_CrosstabJP;
            return Execute.DoStoreProcedure(sql, true);
        }
        public DataTable QBChangNG(DateTime Date)
        {
            string sql = clsConstBasicListFuction.ClsReportFuction.BCKH.QBChangNG;
            var parameter = new SqlParameter[]
                {
                    CreateParameter("@Date", SqlDbType.DateTime, Date)
                    
                };
            return Execute.DoStoreGetByID(sql, parameter, true);
        }
        public DataTable Qketquagiaconghangloat(DateTime Date)
        {
            string sql = clsConstBasicListFuction.ClsReportFuction.BCKH.Qketquagiaconghangloat;
            var parameter = new SqlParameter[]
                {
                    CreateParameter("@Date", SqlDbType.DateTime, Date)
                    
                };
            return Execute.DoStoreGetByID(sql, parameter, true);
        }
        public DataTable Qketquachaythu(DateTime Date)
        {
            string sql = clsConstBasicListFuction.ClsReportFuction.BCKH.Qketquachaythu;
            var parameter = new SqlParameter[]
                {
                    CreateParameter("@Date", SqlDbType.DateTime, Date)
                    
                };
            return Execute.DoStoreGetByID(sql, parameter, true);
        }
        #endregion
        #region Các bảng dữ liệu cần import để làm báo cáo
        //bảng import
        public DataTable Tnhaporder()
        {
            string sql = clsConstBasicListFuction.ClsReportFuction.TableImport.Tnhaporder;
            return Execute.DoStoreProcedure(sql, true);
        }
        public DataTable XTDonhangmuangoai()
        {
            string sql = clsConstBasicListFuction.ClsReportFuction.TableImport.XTDonhangmuangoai;
            return Execute.DoStoreProcedure(sql, true);
        }
        public DataTable NhapOrderDonHangChuyenKho()
        {
            string sql = clsConstBasicListFuction.ClsReportFuction.TableImport.NhapOrderDonHangChuyenKho;
            return Execute.DoStoreProcedure(sql, true);
        }
        public DataTable HENKH()
        {
            string sql = clsConstBasicListFuction.ClsReportFuction.TableImport.HENKH;
            return Execute.DoStoreProcedure(sql, true);
        }

        public DataTable MachineWTS_Temp()
        {
            string sql = clsConstBasicListFuction.ClsReportFuction.TableImport.MachineWTS_Temp;
            return Execute.DoStoreProcedure(sql, true);
        }

        public DataTable WorkName()
        {
            string sql = clsConstBasicListFuction.ClsReportFuction.TableImport.WorkName;
            return Execute.DoStoreProcedure(sql, true);
        }

        public DataTable Shift()
        {
            string sql = clsConstBasicListFuction.ClsReportFuction.TableImport.Shift;
            return Execute.DoStoreProcedure(sql, true);
        }

        public DataTable Thuy0480()
        {
            string sql = clsConstBasicListFuction.ClsReportFuction.TableImport.Thuy0480;
            return Execute.DoStoreProcedure(sql, true);
        }

        public DataTable InternalNGDetails()
        {
            string sql = clsConstBasicListFuction.ClsReportFuction.TableImport.InternalNGDetails;
            return Execute.DoStoreProcedure(sql, true);
        }

        public DataTable MachineList()
        {
            string sql = clsConstBasicListFuction.ClsReportFuction.TableImport.MachineList;
            return Execute.DoStoreProcedure(sql, true);
        }

        public DataTable MistakeList()
        {
            string sql = clsConstBasicListFuction.ClsReportFuction.TableImport.MistakeList;
            return Execute.DoStoreProcedure(sql, true);
        }

        public DataTable CauseList()
        {
            string sql = clsConstBasicListFuction.ClsReportFuction.TableImport.CauseList;
            return Execute.DoStoreProcedure(sql, true);
        }

        public DataTable TimeCard()
        {
            string sql = clsConstBasicListFuction.ClsReportFuction.TableImport.TimeCard;
            return Execute.DoStoreProcedure(sql, true);
        }

        public DataTable StaffList()
        {
            string sql = clsConstBasicListFuction.ClsReportFuction.TableImport.StaffList;
            return Execute.DoStoreProcedure(sql, true);
        }

        public DataTable StaffList1()
        {
            string sql = clsConstBasicListFuction.ClsReportFuction.TableImport.StaffList1;
            return Execute.DoStoreProcedure(sql, true);
        }

        public DataTable TimeCard1()
        {
            string sql = clsConstBasicListFuction.ClsReportFuction.TableImport.TimeCard1;
            return Execute.DoStoreProcedure(sql, true);
        }
        #endregion

        #region xóa dữ liệu tại các bảng
        public void DeleteTnhaporder()
        {
            string sql = clsConstBasicListFuction.ClsReportFuction.TableDelete.Tnhaporder;
            Execute.DoStoreProcedure(sql, true);
        }   //0

        public void DeleteXTDonhangmuangoai()
        {
            string sql = clsConstBasicListFuction.ClsReportFuction.TableDelete.XTDonhangmuangoai;
            Execute.DoStoreProcedure(sql, true);
        }//1

        public void DeleteNhapOrderDonHangChuyenKho()
        {
            string sql = clsConstBasicListFuction.ClsReportFuction.TableDelete.NhapOrderDonHangChuyenKho;
            Execute.DoStoreProcedure(sql, true);
        }//2

        public void DeleteHENKH()
        {
            string sql = clsConstBasicListFuction.ClsReportFuction.TableDelete.HENKH;
            Execute.DoStoreProcedure(sql, true);
        }//3

        public void DeleteNhaplenhtinhthoigianGC()
        {
            string sql = clsConstBasicListFuction.ClsReportFuction.TableDelete.NhaplenhtinhthoigianGC;
            Execute.DoStoreProcedure(sql, true);
        }//4

        public void DeleteNhapOrderlapKHGC()
        {
            string sql = clsConstBasicListFuction.ClsReportFuction.TableDelete.NhapOrderlapKHGC;
            Execute.DoStoreProcedure(sql, true);
        }//5

        public void DeleteNhapOrderlapKHNCV()
        {
            string sql = clsConstBasicListFuction.ClsReportFuction.TableDelete.NhapOrderlapKHNCV;
            Execute.DoStoreProcedure(sql, true);
        }//6

        public void DeleteNhapOrderlapKHKtra()
        {
            string sql = clsConstBasicListFuction.ClsReportFuction.TableDelete.NhapOrderlapKHKtra;
            Execute.DoStoreProcedure(sql, true);
        }//7

        public void DeleteMachineWTS_Temp()
        {
            string sql = clsConstBasicListFuction.ClsReportFuction.TableDelete.MachineWTS_Temp;
            Execute.DoStoreProcedure(sql, true);
        }

        public void DeleteWorkName()
        {
            string sql = clsConstBasicListFuction.ClsReportFuction.TableDelete.WorkName;
            Execute.DoStoreProcedure(sql, true);
        }

        public void DeleteShift()
        {
            string sql = clsConstBasicListFuction.ClsReportFuction.TableDelete.Shift;
            Execute.DoStoreProcedure(sql, true);
        }

        public void DeleteThuy0480()
        {
            string sql = clsConstBasicListFuction.ClsReportFuction.TableDelete.Thuy0480;
            Execute.DoStoreProcedure(sql, true);
        }

        public void DeleteInternalNGDetails()
        {
            string sql = clsConstBasicListFuction.ClsReportFuction.TableDelete.InternalNGDetails;
            Execute.DoStoreProcedure(sql, true);
        }

        public void DeleteMachineList()
        {
            string sql = clsConstBasicListFuction.ClsReportFuction.TableDelete.MachineList;
            Execute.DoStoreProcedure(sql, true);
        }

        public void DeleteMistakeList()
        {
            string sql = clsConstBasicListFuction.ClsReportFuction.TableDelete.MistakeList;
            Execute.DoStoreProcedure(sql, true);
        }

        public void DeleteCauseList()
        {
            string sql = clsConstBasicListFuction.ClsReportFuction.TableDelete.CauseList;
            Execute.DoStoreProcedure(sql, true);
        }

        public void DeleteTimeCard()
        {
            string sql = clsConstBasicListFuction.ClsReportFuction.TableDelete.TimeCard;
            Execute.DoStoreProcedure(sql, true);
        }

        public void DeleteStaffList()
        {
            string sql = clsConstBasicListFuction.ClsReportFuction.TableDelete.StaffList;
            Execute.DoStoreProcedure(sql, true);
        }

        public void DeleteStaffList1()
        {
            string sql = clsConstBasicListFuction.ClsReportFuction.TableDelete.StaffList1;
            Execute.DoStoreProcedure(sql, true);
        }

        public void DeleteTimeCard1()
        {
            string sql = clsConstBasicListFuction.ClsReportFuction.TableDelete.TimeCard1;
            Execute.DoStoreProcedure(sql, true);
        }

        #endregion
    }
}
